home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / surfsrc3.zip / DRAWAXES.INC < prev    next >
Text File  |  1989-08-10  |  4KB  |  87 lines

  1. procedure DRAWAXES (Xfotran, Yfotran, XYmax: real);
  2. { Draw axes on the screen, if requested }
  3.  
  4. var OriginX, OriginY, OriginZ: real;    { transformed (2-D) coords of origin }
  5.     XaxisX,  XaxisY,  XaxisZ:  real;    { transformed coords of end of X axis }
  6.     YaxisX,  YaxisY,  YaxisZ:  real;    { transformed coords of end of Y axis }
  7.     ZaxisX,  ZaxisY,  ZaxisZ:  real;    { transformed coords of end of Z axis }
  8.     Xoffset, Yoffset:          real;    { amt to offset axes from real origin }
  9.     Xchar, Ychar:              integer; { half the size of a character }
  10.     Outp: text;
  11.  
  12. begin
  13.   if (Showaxes > 0) then begin
  14.     perspect (0.0, 0.0, 0.0, OriginX, OriginY, OriginZ);
  15.     perspect (Xaxislen, 0.0, 0.0, XaxisX, XaxisY, XaxisZ);
  16.     perspect (0.0, Yaxislen, 0.0, YaxisX, YaxisY, YaxisZ);
  17.     perspect (0.0, 0.0, Zaxislen, ZaxisX, ZaxisY, ZaxisZ);
  18.     normalize (OriginX, OriginY, Xfotran, Yfotran, XYmax);
  19.     normalize (XaxisX,  XaxisY,  Xfotran, Yfotran, XYmax);
  20.     normalize (YaxisX,  YaxisY,  Xfotran, Yfotran, XYmax);
  21.     normalize (ZaxisX,  ZaxisY,  Xfotran, Yfotran, XYmax);
  22.  
  23. { Offset the origin of the axes to put it in the lower left corner }
  24.     Xoffset := OriginX - Gxmin - (Gxmax - Gxmin) * 0.1;
  25.     Yoffset := OriginY - Gymax + (Gymax - Gymin) * 0.1;
  26.  
  27.     OriginX := OriginX - Xoffset;
  28.     OriginY := OriginY - Yoffset;
  29.     XaxisX  := XaxisX  - Xoffset;
  30.     XaxisY  := XaxisY  - Yoffset;
  31.     YaxisX  := YaxisX  - Xoffset;
  32.     YaxisY  := YaxisY  - Yoffset;
  33.     ZaxisX  := ZaxisX  - Xoffset;
  34.     ZaxisY  := ZaxisY  - Yoffset;
  35.  
  36. { Draw the axes }
  37.     gdraw (round(OriginX), round(OriginY), round(XaxisX), round(XaxisY),
  38.            Axiscolor);
  39.     gdraw (round(OriginX), round(OriginY), round(YaxisX), round(YaxisY),
  40.            Axiscolor);
  41.     gdraw (round(OriginX), round(OriginY), round(ZaxisX), round(ZaxisY),
  42.            Axiscolor);
  43.  
  44. { Find the position for the axis labels, about 1.2 time the axis length
  45.   from the origin }
  46.     perspect (1.2*Xaxislen, 0.0, 0.0, XaxisX, XaxisY, XaxisZ);
  47.     perspect (0.0, 1.2*Yaxislen, 0.0, YaxisX, YaxisY, YaxisZ);
  48.     perspect (0.0, 0.0, 1.2*Zaxislen, ZaxisX, ZaxisY, ZaxisZ);
  49.     normalize (XaxisX,  XaxisY,  Xfotran, Yfotran, XYmax);
  50.     normalize (YaxisX,  YaxisY,  Xfotran, Yfotran, XYmax);
  51.     normalize (ZaxisX,  ZaxisY,  Xfotran, Yfotran, XYmax);
  52.  
  53.     XaxisX  := XaxisX  - Xoffset;
  54.     XaxisY  := XaxisY  - Yoffset;
  55.     YaxisX  := YaxisX  - Xoffset;
  56.     YaxisY  := YaxisY  - Yoffset;
  57.     ZaxisX  := ZaxisX  - Xoffset;
  58.     ZaxisY  := ZaxisY  - Yoffset;
  59.  
  60. { Now draw the labels }
  61.     Xchar := (Gxmax - Gxmin) div 160;
  62.     Ychar := (Gymax - Gymin) div 50;
  63.  
  64. { Draw an X }
  65.     gdraw (round(XaxisX-Xchar), round(XaxisY-Ychar),
  66.            round(XaxisX+Xchar), round(XaxisY+Ychar), Axiscolor);
  67.     gdraw (round(XaxisX-Xchar), round(XaxisY+Ychar),
  68.            round(XaxisX+Xchar), round(XaxisY-Ychar), Axiscolor);
  69.  
  70. { Draw a Y }
  71.     gdraw (round(YaxisX-Xchar), round(YaxisY-Ychar),
  72.            round(YaxisX), round(YaxisY), Axiscolor);
  73.     gdraw (round(YaxisX+Xchar), round(YaxisY-Ychar),
  74.            round(YaxisX), round(YaxisY), Axiscolor);
  75.     gdraw (round(YaxisX), round(YaxisY),
  76.            round(YaxisX), round(YaxisY+Ychar), Axiscolor);
  77.  
  78. { Draw a Z }
  79.     gdraw (round(ZaxisX-Xchar), round(ZaxisY-Ychar),
  80.            round(ZaxisX+Xchar), round(ZaxisY-Ychar), Axiscolor);
  81.     gdraw (round(ZaxisX+Xchar), round(ZaxisY-Ychar),
  82.            round(ZaxisX-Xchar), round(ZaxisY+Ychar), Axiscolor);
  83.     gdraw (round(ZaxisX-Xchar), round(ZaxisY+Ychar),
  84.            round(ZaxisX+Xchar), round(ZaxisY+Ychar), Axiscolor);
  85.   end; { if Showaxes }
  86. end; { procedure DRAWAXES }
  87.